<#include "/layout/header.ftl"/>
<div class="clearfix">

</div>
<div class="row" >
    <div class="col-md-12 col-sm-12 col-xs-12">
        <ol class="breadcrumb">
            <li class="active">人力资源审核</li>
        </ol>
        <div class="x_panel">
            <div class="x_content">
                <div class="<#--table-responsive-->">
                    <div class="btn-group hidden-xs" id="toolbar">
                        <#--<@shiro.hasPermission name="talentshare">-->
                            <#--<button id="btn_add" type="button" class="btn btn-default" title="新增资源">-->
                                <#--<i class="fa fa-plus"></i> 新增资源-->
                            <#--</button>-->
                        <#--</@shiro.hasPermission>-->
                        <@shiro.hasPermission name="talentshare">
                            <button id="btn_delete_ids" type="button" class="btn btn-default" title="删除选中">
                                <i class="fa fa-trash-o"></i> 批量删除
                            </button>
                        </@shiro.hasPermission>
                    </div>
                    <div class="pull-right" id="query-form" style="padding-top:10px;padding-left: 5px">
                        <input id="title" name="lookupType"  type="text"
                               style="float:left;width:150px;margin-right:5px;" placeholder="请输入标题" v-model="lookupType"
                               class="form-control">
                        <#--<div style="float:left;margin-right:5px;">-->
                            <#--<input name="description"  type="text"-->
                                   <#--style="float:left;width:150px;margin-right:5px;" v-model="description"-->
                                   <#--class="form-control">-->
                        <#--</div>-->

                        <div class="btn-group">
                            <button id="btn_search" onclick="customSearch()" type="button" class="btn btn-primary btn-space">
                                <span class="fa fa-search" aria-hidden="true" class="btn-icon-space"></span>
                            </button>
                        </div>

                    </div>

                    <table id="tablelist" data-query-params="queryParams" data-query-params-type="limit" >
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<#include "/layout/footer.ftl"/>
<script>
    /**
     * 操作按钮
     * @param code
     * @param row
     * @param index
     * @returns {string}
     */
    function operateFormatter(code, row, index) {
        var trId = row.id;
        var operateBtn = [
            '<@shiro.hasPermission name="talentshare"><a class="btn btn-xs btn-primary " href="javascript:sucess(' + trId + ')"><i class="fa fa-edit"></i>审核成功</a></@shiro.hasPermission>',
            '<@shiro.hasPermission name="talentshare"><a class="btn btn-xs btn-danger " href="javascript:fail(' + trId + ')"><i class="fa fa-trash-o"></i>审核失败</a></@shiro.hasPermission>'
        ];
        if(row.state==0)
        return operateBtn.join('');
        else if(row.state==1||row.state==2){
            return '<a class="btn btn-xs btn-danger btn-remove" data-id="' + trId + '"><i class="fa fa-trash-o"></i>删除</a>';
        }
    }

    function queryParams(){
        var temp = {
            title:$("#title").val()
        };
        return temp;
    }
    function customSearch(){
        $("#tablelist").bootstrapTable('refresh');
    }
    $(function () {
        var options = {
            hasParams:true,
            getParams:queryParams,
            url: "/talentshare/list",
           // getInfoUrl: "/resources/get/{id}",
           //  updateUrl: "/talentshare/sucess/{id}",
            removeUrl: "/talentshare/remove",
            //createUrl: "/talentshare/add",
            //saveRolesUrl: "/talentshare/save",
            columns: [{
                checkbox: true
            }, {
                field: 'title',
                title: '标题',
                editable: true
            }, {
                field: 'type',
                title: '兼职/全职',
                editable: true,
                formatter: function (code) {
                    return code == '0' ? '全职' : '兼职';
                }
            }, {
                field: 'mold',
                title: '简历/招聘',
                editable: true,
                formatter: function (code) {
                    return code == '0' ? '简历' : '招聘';
                }
            }, {
                field: 'position',
                title: '职位',
                editable: true
            }, {
                field: 'date',
                title: '工作日期',
                editable: false
            }, {
                field: 'request',
                title: '求职要求以及描述',
                editable: true
            }, {
                field: 'region_id',
                title: '地域信息',
                editable: true
            }, {
                field: '创建时间',
                title: 'creat_time',
                editable: false
            },{
                field: 'operate',
                title: '操作',
                formatter: operateFormatter //自定义方法，添加操作按钮
            }],
            modalName: "人才共享"
        }
        //1.初始化Table
        $.tableUtil.init(options);
        //2.初始化Button的点击事件
        $.buttonUtil.init(options);

    });

    function fail(id) {
        $.tool.confirm("确定拒绝该条信息？", function () {
            $.ajax({
                type: "put",
                url: "/talentshare/fault/" + id,
                success: function (json) {
                    $.tool.ajaxSuccess(json);
                    $.tableUtil.refresh();
                },
                error: $.tool.ajaxError
            });
        }, function () {

        }, 5000);
    }
    function sucess(id) {
        $.tool.confirm("确定同意该条信息？", function () {
            $.ajax({
                type: "put",
                url: "/talentshare/success/" + id,
                success: function (json) {
                    debugger;
                    $.tool.ajaxSuccess(json);
                    $.tableUtil.refresh();
                },
                error: $.tool.ajaxError
            });
        }, function () {

        }, 5000);
    }

</script>